//
//  HJDTableViewController.m
//  网易
//
//  Created by 胡金东 on 16/5/9.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDMondayTableViewController.h"
#import "HJDModel.h"

@interface HJDMondayTableViewController ()<UIScrollViewDelegate>

@property (nonatomic,strong) NSArray * taskArr;
@property (nonatomic,assign) CGRect rect;
@property (nonatomic,strong)UIScrollView *scroll;



@end

@implementation HJDMondayTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.taskArr = [HJDModel taskArray];
    [self setUplbl];
    
    

    }

#pragma mark - Table view data source

-(void)setUplbl{
    
    self.scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0,355 , 180)];
    self.scroll.delegate = self;
    self.scroll.backgroundColor = [UIColor whiteColor];
    
    self.automaticallyAdjustsScrollViewInsets = YES;
    self.scroll.showsVerticalScrollIndicator = YES;//垂直移动
    self.scroll.showsHorizontalScrollIndicator = NO;//水平移动
    //上下滑动
    
    [self.view addSubview:self.scroll];
    
    HJDModel *model = self.taskArr[0];
    UILabel *one = [[UILabel alloc]initWithFrame:CGRectZero];
    one.text = model.taskArray[0];
    one.textColor = [UIColor getColorWithHexNumber:@"333333"];
    one.font = [UIFont systemFontOfSize:15];
    one.numberOfLines = 0;
   
    CGFloat oneX = 10;
    CGFloat oneY = 0;
    CGFloat oneW = HJDWidth - HJDHorizontalMargin * 2 ;
    CGRect oneRect = [one.text boundingRectWithSize:CGSizeMake(oneW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:one.font,NSFontAttributeName, nil] context:nil];
    one.frame = (CGRect){{oneX,oneY},oneRect.size};
    [self.scroll addSubview:one];
    //    横线
    CGFloat oneviewX = 10 ;
    CGFloat oneviewY = CGRectGetMaxY(one.frame);
    CGFloat oneviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat oneviewH = 1;
    UIView *oneview = [[UIView alloc]initWithFrame:CGRectMake(oneviewX, oneviewY, oneviewW, oneviewH)];
    oneview.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    [self.scroll addSubview:oneview];
   
    UILabel *two = [[UILabel alloc]initWithFrame:CGRectZero];
    two.text = model.taskArray[1];
    two.textColor = [UIColor getColorWithHexNumber:@"333333"];
    two.font = [UIFont systemFontOfSize:15];
    two.numberOfLines = 0;
    
    CGFloat twoX = 10;
    CGFloat twoY = CGRectGetMaxY(oneview.frame);
    CGFloat twoW = HJDWidth - HJDHorizontalMargin * 2 ;
    CGRect twoRect = [two.text boundingRectWithSize:CGSizeMake(twoW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:two.font,NSFontAttributeName, nil] context:nil];
    two.frame = (CGRect){{twoX,twoY},twoRect.size};
    [self.scroll addSubview:two];
    
    //    横线
    CGFloat twoviewX = 10 ;
    CGFloat twoviewY = CGRectGetMaxY(two.frame);
    CGFloat twoviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat twoviewH = 1;
    UIView *twoview = [[UIView alloc]initWithFrame:CGRectMake(twoviewX, twoviewY, twoviewW, twoviewH)];
    twoview.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    [self.scroll addSubview:twoview];
    
 
    UILabel *three = [[UILabel alloc]initWithFrame:CGRectZero];
    three.text = model.taskArray[2];
    three.textColor = [UIColor getColorWithHexNumber:@"333333"];
    three.font = [UIFont systemFontOfSize:15];
    three.numberOfLines = 0;
    
    CGFloat threeX = 10;
    CGFloat threeY = CGRectGetMaxY(twoview.frame);
    CGFloat threeW = HJDWidth - HJDHorizontalMargin * 2 ;
    CGRect threeRect = [three.text boundingRectWithSize:CGSizeMake(threeW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:three.font,NSFontAttributeName, nil] context:nil];
    three.frame = (CGRect){{threeX,threeY},threeRect.size};
    [self.scroll addSubview:three];
    
    //    横线
    CGFloat threeviewX = 10 ;
    CGFloat threeviewY = CGRectGetMaxY(three.frame);
    CGFloat threeviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat threeviewH = 1;
    UIView *threeview = [[UIView alloc]initWithFrame:CGRectMake(threeviewX, threeviewY, threeviewW, threeviewH)];
    threeview.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    [self.scroll addSubview:threeview];
    
   
    UILabel *four = [[UILabel alloc]initWithFrame:CGRectZero];
    four.text = model.taskArray[3];
    four.textColor = [UIColor getColorWithHexNumber:@"333333"];
    four.font = [UIFont systemFontOfSize:15];
    four.numberOfLines = 0;
    
    CGFloat fourX = 10;
    CGFloat fourY = CGRectGetMaxY(threeview.frame);
    CGFloat fourW = HJDWidth - HJDHorizontalMargin * 2 ;
    CGRect fourRect = [four.text boundingRectWithSize:CGSizeMake(fourW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:four.font,NSFontAttributeName, nil] context:nil];
    four.frame = (CGRect){{fourX,fourY},fourRect.size};
    [self.scroll addSubview:four];
    
    //    横线
    CGFloat fourviewX = 10 ;
    CGFloat fourviewY = CGRectGetMaxY(four.frame);
    CGFloat fourviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat fourviewH = 1;
    UIView *fourview = [[UIView alloc]initWithFrame:CGRectMake(fourviewX, fourviewY, fourviewW, fourviewH)];
    fourview.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    [self.scroll addSubview:fourview];
    
    self.scroll.contentSize = CGSizeMake(355, oneRect.size.height + twoRect.size.height + threeRect.size.height + fourRect.size.height + 4) ;

}

//
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//
//    return 4;
//}
//
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//   static NSString *identifier = @"cell";
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
//    if (cell == nil) {
//        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
//    }
// 
//    HJDModel *model = self.taskArr[0];
//    cell.textLabel.text = model.taskArray[indexPath.row];
//    cell.textLabel.font = [UIFont systemFontOfSize:15];
//    cell.textLabel.numberOfLines = 0;
//     _rect = [cell.textLabel.text boundingRectWithSize:CGSizeMake(self.view.frame.size.width -30, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys: cell.textLabel.font,NSFontAttributeName, nil] context:nil];
//    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
//    HJDLog(@"%@",cell.textLabel.text);
//    return cell;
//}
//-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//   
//    return _rect.size.height;
//}
//




@end
